from py_stealth import *

friends = [0x025F]
pets = [0x031F]

def FindTarget(target_types):
    SetFindDistance(1)
    for friendType in target_types:
        FindType(friendType, Ground())
        if IsDead(FindItem()):
            return FindItem()
    return 0


def GetBandage():
    FindType(0x0E21, Backpack())
    if FindQuantity() > 1:
        return FindItem()
    return 0

def DropSrcoll():
    if FindType(0x226C, Backpack()):
        Drop(FindItem(), 1, GetX(Self()), GetY(Self()), GetY(Self()))


while True:
    _friend = FindTarget(friends)
    _pet = FindTarget(pets)
    _bandage = GetBandage()

    if _friend:
        CastToObj('Resurrection', _friend)
    elif _bandage and _pet:
        bandage = FindItem()
        UseObject(bandage)
        WaitForTarget(3000)
        TargetToObject(_pet)
    elif not IsHidden(Self()):
        CastToObj('Invisibility', Self())
    Wait(3000)
